import request from '@/utils/request'
import JSONBigInt from 'json-bigint'
let URL= 'teacher-oa'
// let URL= ''

//查询考勤组列表
export function list(query) {
  return request({
    url: URL + '/v1/attgroup/list',
    method: 'get',
    params: query
  })
}
//查询考勤组列表-简单信息
export function samplelist(query) {
  return request({
    url: URL + '/v1/attgroup/samplelist',
    method: 'get',
    params: query
  })
}

//新增考勤班次
export function attshiftEdit(data) {
  return request({
    url: URL + '/v1/attshift/edit',
    method: 'post',
    data
  })
}

//考勤组考勤对象校验
export function membercheck(query) {
  return request({
    url: URL + '/v1/attgroup/membercheck',
    method: 'get',
    params: query
  })
}

//通过id删除考勤组-考勤负责人
export function oaattendancegroupmember(query) {
  return request({
    url: URL + '/v1/oaattendancegroupmember',
    method: 'delete',
    params: query
  })
}

//新增考勤班次
export function attshiftSave(data) {
  return request({
    url: URL + '/v1/attshift/save',
    method: 'post',
    data
  })
}

export function attshiftRemove(data) {
  return request({
    url: URL + '/v1/attshift/remove/'+data.id,
    method: 'post',
    data
  })
}


export function attshiftList(query) {
  return request({
    url: URL + '/v1/attshift/list',
    method: 'get',
    params: query
  })
}



//新增考勤班次
export function attgroupStatus(data) {
  return request({
    url: URL + '/v1/attgroup/status/'+data.id+'/'+data.groupStatus,
    method: 'post',
    data
  })
}

export function attgroupgpsplaceEdit (data) {
  return request({
    url: URL + '/v1/attgroupgpsplace/edit',
    method: 'post',
    data
  })
}

export function attgroupgpsplaceSave (data) {
  return request({
    url: URL + '/v1/attgroupgpsplace/save',
    method: 'post',
    data
  })
}

export function attgroupgpsplaceRemove (data) {
  return request({
    url: URL + '/v1/attgroupgpsplace/remove/'+data.id,
    method: 'post',
  })
}


//通过id查询-基本信息
export function getBase(id) {
  return request({
    url: URL + '/v1/attgroup/base/' + id,
    method: 'get',
  })
}

//通过id删除考勤组
export function remove(id) {
  return request({
    url: URL + '/v1/attgroup/remove/' + id,
    method: 'post',
  })
}

//保存考勤组-基本信息
export function save(data) {
  return request({
    url: URL + '/v1/attgroup/base/save',
    method: 'post',
    data,
    transformResponse:[function(data) {
      return JSONBigInt.parse(data)
    }]
  })
}

//通过id查询-考勤班次
export function shift(id) {
  return request({
    url: URL + '/v1/attgroup/shift/' + id,
    method: 'get',
  })
}

//保存考勤组-考勤班次
export function shiftSave(data) {
  return request({
    url: URL + '/v1/attgroup/shift/save',
    method: 'post',
    data
  })
}

//通过id查询-考勤方式
export function type(id) {
  return request({
    url: URL + '/v1/attgroup/type/' + id,
    method: 'get',
  })
}

//保存考勤组-考勤方式
export function typeSave(data) {
  return request({
    url: URL + '/v1/attgroup/type/save',
    method: 'post',
    data
  })
}

//通过id查询-考勤规则
export function rule(id) {
  return request({
    url: URL + '/v1/attgroup/rule/' + id,
    method: 'get',
  })
}

//保存考勤组-考勤规则
export function ruleSave(data) {
  return request({
    url: URL + '/v1/attgroup/rule/save',
    method: 'post',
    data
  })
}

//考勤统计-日统计分页查询
export function page(query) {
  return request({
    url: URL + '/v1/attstatistics/daily/page',
    method: 'get',
    params: query
  })
}

//考勤统计-月周统计分页查询
export function rangePage(query) {
  return request({
    url: URL + '/v1/attstatistics/range/page',
    method: 'get',
    params: query
  })
}

//考勤统计-按此统计
export function timePage(query) {
  return request({
    url: URL + '/v1/attstatistics/record/times/page',
    method: 'get',
    params: query
  })
}

//考勤记录-显示时间的分页查询
export function dailyPage(query) {
  return request({
    url: URL + '/v1/attstatistics/record/daily/page',
    method: 'get',
    params: query
  })
}

export function getGPS(data) {
  return request({
    // url: 'https://restapi.amap.com/v3/place/text?key=e262abcee1788b047b358086baa51fcc&keywords='+data.keywords+'&types=&city='+data.city+'&children=1&offset=20&page=1&extensions=all',
    url: URL + '/v1/attgroupgpsplace/place' + '?key=e262abcee1788b047b358086baa51fcc&keywords='+data.keywords+'&types=&city='+data.city+'&children=1&offset=20&page=1&extensions=all',
    method: 'get',
  })
}

export function getPunchTitle(id) {
  return request({
    url: URL + '/v1/attstatistics/record/times/getPunchTitle',
    method: 'get',
  })
}
